//
//  KKVideoPayDialog.m
//  DoMi
//
//  Created by 康凯 on 2016/11/25.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKVideoPayDialog.h"

@interface KKVideoPayDialog()
@property (weak, nonatomic) IBOutlet UIButton *currentCourseBtn;
@property (weak, nonatomic) IBOutlet UIButton *seasonCourseBtn;
@property (weak, nonatomic) IBOutlet UIButton *allCourseBtn;

@property (copy,nonatomic)NSString *buyItem;
@end
@implementation KKVideoPayDialog

-(void)awakeFromNib{
    [super awakeFromNib];
    self.container.autoresizingMask =UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.container.translatesAutoresizingMaskIntoConstraints = YES;
    
    self.frame = [UIScreen mainScreen].bounds;
    self.container.frame=CGRectMake(8, screenHeight, screenWidth-16, 303);
    self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
    
    self.currentCourseBtn.selected=YES;
    self.buyItem=@"dj";
}

#pragma mark 按钮--取消
- (IBAction)cancelBtn:(id)sender {
[self dismiss];
}

#pragma makr 弹框--展示
-(void)show{
    self.currentJF.text=[NSString stringWithFormat:@"(%@积分)",self.buyInfo.dj.jifen];
    self.currentCoursePrice.text=[NSString stringWithFormat:@"¥  %@",self.buyInfo.dj.price];
    self.quarterPrice.text=[NSString stringWithFormat:@"¥  %@",self.buyInfo.jd.price];
    self.allPrice.text=[NSString stringWithFormat:@"¥  %@",self.buyInfo.qb.price];
    [appWindow addSubview:self];
    [UIView animateWithDuration:dialog_animation_time animations:^{
        self.container.transform = CGAffineTransformMakeTranslation(0,-311);
    }];
}
#pragma makr 弹框--消失
-(void)dismiss{
    [UIView animateWithDuration:dialog_animation_time animations:^{
        [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
        self.container.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

#pragma mark 按钮
- (IBAction)currentCourseClick:(id)sender {
    self.buyItem=@"dj";
    self.currentCourseBtn.selected=YES;
    self.seasonCourseBtn.selected=NO;
    self.allCourseBtn.selected=NO;
}
- (IBAction)seasonCourseClick:(id)sender {
    self.buyItem=@"jd";
    self.currentCourseBtn.selected=NO;
    self.seasonCourseBtn.selected=YES;
    self.allCourseBtn.selected=NO;
}
- (IBAction)allCourseClick:(id)sender {
    self.buyItem=@"qb";
    self.currentCourseBtn.selected=NO;
    self.seasonCourseBtn.selected=NO;
    self.allCourseBtn.selected=YES;
}

- (IBAction)aliPayClick:(id)sender {
    self.aliPayBlock(self.buyItem);
    [self dismiss];
}
- (IBAction)wXpayClick:(id)sender {
    self.wXPayBlock(self.buyItem);
    [self dismiss];
}
- (IBAction)jiFenClick:(id)sender {
    if(!self.currentCourseBtn.isSelected){
        [KKAppUtils toast:@"此选项不支持积分支付"];
        return;
    }
    [self dismiss];
    self.jiFenPayBlock();
}

@end
